﻿--日零担开单量
BEGIN
  EXECUTE IMMEDIATE 'DROP TABLE tb_Daily_LTTL';
EXCEPTION
  WHEN OTHERS THEN
    IF sqlcode != -0942 THEN RAISE; END IF;
END;
/

--LTTL=Less_than_Truck_Load
create table tb_Daily_LTTL
(
  ID number(9) primary key,
  BS_COUNT number(9),
  CREATETIME DATE
);
/

BEGIN
  EXECUTE IMMEDIATE 'DROP SEQUENCE tb_Daily_LTTL_Seq';
EXCEPTION
  WHEN OTHERS THEN
    IF sqlcode != -2289 THEN raise; END IF;
END;
/

CREATE SEQUENCE tb_Daily_LTTL_Seq
 INCREMENT BY 1   -- 每次加几个  
     START WITH 1     -- 从1开始计数  
     NOMAXVALUE       -- 不设置最大值  
     NOCYCLE          -- 一直累加，不循环  
     CACHE 10;
/

CREATE or REPLACE TRIGGER tb_Daily_LTTL_Tri BEFORE
insert ON  tb_Daily_LTTL FOR EACH ROW
begin
select tb_Daily_LTTL_Seq.nextval into:New.ID from dual;
end
commit;
/


--日快递开单量
BEGIN
  EXECUTE IMMEDIATE 'DROP TABLE tb_Daily_ED';
EXCEPTION
  WHEN OTHERS THEN
    IF sqlcode != -0942 THEN RAISE; END IF;
END;
/
--Express_Delivery= ED
create table tb_Daily_ED
(
  ID number(9) primary key,
  BS_COUNT number(9),
  CREATETIME DATE
);
/

BEGIN
  EXECUTE IMMEDIATE 'DROP SEQUENCE tb_Daily_ED_Seq';
EXCEPTION
  WHEN OTHERS THEN
    IF sqlcode != -2289 THEN raise; END IF;
END;
/

CREATE SEQUENCE tb_Daily_ED_Seq
 INCREMENT BY 1   -- 每次加几个  
     START WITH 1     -- 从1开始计数  
     NOMAXVALUE       -- 不设置最大值  
     NOCYCLE          -- 一直累加，不循环  
     CACHE 10;
/

CREATE or REPLACE TRIGGER tb_Daily_ED_Tri BEFORE
insert ON  tb_Daily_ED FOR EACH ROW
begin
select tb_Daily_ED_Seq.nextval into:New.ID from dual;
end
commit;
/


--周零担开单量
BEGIN
  EXECUTE IMMEDIATE 'DROP TABLE tb_Weekly_LTTL';
EXCEPTION
  WHEN OTHERS THEN
    IF sqlcode != -0942 THEN RAISE; END IF;
END;
/
create table tb_Weekly_LTTL
(
  ID number(9) primary key,
  BS_COUNT number(9),
  CREATETIME DATE
);
/

BEGIN
  EXECUTE IMMEDIATE 'DROP SEQUENCE tb_Weekly_LTTL_Seq';
EXCEPTION
  WHEN OTHERS THEN
    IF sqlcode != -2289 THEN raise; END IF;
END;
/

CREATE SEQUENCE tb_Weekly_LTTL_Seq
 INCREMENT BY 1   -- 每次加几个  
     START WITH 1     -- 从1开始计数  
     NOMAXVALUE       -- 不设置最大值  
     NOCYCLE          -- 一直累加，不循环  
     CACHE 10;
/
CREATE or REPLACE TRIGGER tb_Weekly_LTTL_Tri BEFORE
insert ON  tb_Weekly_LTTL FOR EACH ROW
begin
select tb_Weekly_LTTL_Seq.nextval into:New.ID from dual;
end
commit;
/

--周快递开单量
BEGIN
  EXECUTE IMMEDIATE 'DROP TABLE tb_Weekly_ED';
EXCEPTION
  WHEN OTHERS THEN
    IF sqlcode != -0942 THEN RAISE; END IF;
END;
/
create table tb_Weekly_ED
(
  ID number(9) primary key,
  BS_COUNT number(9),
  CREATETIME DATE
);
/

BEGIN
  EXECUTE IMMEDIATE 'DROP SEQUENCE tb_Weekly_ED_Seq';
EXCEPTION
  WHEN OTHERS THEN
    IF sqlcode != -2289 THEN raise; END IF;
END;
/

CREATE SEQUENCE tb_Weekly_ED_Seq
 INCREMENT BY 1   -- 每次加几个  
     START WITH 1     -- 从1开始计数  
     NOMAXVALUE       -- 不设置最大值  
     NOCYCLE          -- 一直累加，不循环  
     CACHE 10;
/
CREATE or REPLACE TRIGGER tb_Weekly_ED_Tri BEFORE
insert ON  tb_Weekly_ED FOR EACH ROW
begin
select tb_Weekly_ED_Seq.nextval into:New.ID from dual;
end
commit;
/
